#include "PlayerScriptFunc.h"
#include "Character/PlayerMgr.h"

using namespace luabridge;

bool RegistPlayerScriptFunc(lua_State* state) 
{
	// 此处主要用来包装PlayerMgr中的函数，不同于Player类直接导出函数
	// 注意不要与player.lua中的函数有名字冲突
    getGlobalNamespace(state).beginNamespace("PlayerMgr")
        .addFunction("GetPlayer",       GetPlayer)
        .addFunction("GetPlayerCount",  GetPlayerCount)
    .endNamespace();
    return true;
}

namespace
{
	Player* GetPlayer(CharIDType id)
	{
		Player* player = g_GetCreatureMgr()->GetPlayer(id);
		return player;
	}

	uint32_t GetPlayerCount()
	{
		return g_GetCreatureMgr()->GetPlayerCount();
	}
}